// i.d(t, { Z: () => OrderedMap })
const toString = e => "" + e
export default class OrderedMap {
  mappingFunction: (e: any) => string
  list: any[]
  map: Record<string, any>
  constructor(e = toString) {
    this.mappingFunction = e
    this.list = []
    this.map = {}
  }
  add(e) {
    const t = this.mappingFunction(e)
    return !this.map[t] && (this.list.push(e), (this.map[t] = e), !0)
  }
  set(e) {
    const t = this.mappingFunction(e)
    return this.map[t] ? ((this.map[t] = e), !0) : (this.add(e), !0)
  }
  count() {
    return this.list.length
  }
  *[Symbol.iterator]() {
    for (const e of this.list) yield e
  }
  getByIndex(e) {
    return this.list[e]
  }
  get(e) {
    return this.map[e]
  }
  copyToList(e) {
    e.push.apply(e, this.list)
    return e
  }
  clear() {
    this.list = []
    this.map = {}
  }
  mapElements(e) {
    return this.list.map(e)
  }
}
